package com.hsh;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;

import java.util.Date;

/**
 * @author: shaohai.huang
 * @date: 2019-09-24
 */
public class TimeClientErrorHandler extends ChannelInboundHandlerAdapter {

    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        ByteBuf m = (ByteBuf) msg;
        try {
            long cur = (m.readUnsignedInt() - 2208988800L) * 1000;
            System.out.println(new Date(cur));
            ctx.close();
        } finally {
            m.release();
        }
    }
}
